﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Db4objects.Db4o;
using DocManagerORM.ORM;
using System.Data.Objects.DataClasses;
using System.Data.Objects;
using System.Reflection;
using System.Windows.Data;

namespace DocManagerORM.Utils
{
    public class CollViewSourceExt<T> : System.Windows.Data.CollectionViewSource where T : EntityObject, new() 
    {
        DocManagerDbEntities m_Entity = null;//  DocManagerDbEntities
        public IList<KeyValuePair<string, string>> ListaValidazione { get; set; }
      
        string m_NomeEntità = string.Empty;
        public Type Tipo { get; set; }
        public string NomeOggetto { get; set; }
        private T OggettoModificato = default(T);


        public CollViewSourceExt(IList<T> PLista) : base()
        {  
            this.Source = PLista;
            foreach (var item in PLista)
	            item.PropertyChanged +=new PropertyChangedEventHandler(item_PropertyChanged);
	                     
        }

        void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {            
           if (ListaValidazione == null) return;
           var datoValidazione = ListaValidazione.Where(x=> x.Key.Equals(e.PropertyName)).FirstOrDefault();
           if (datoValidazione.Value == null) return;


        }//fM

    }

}
